<%--
  Created by IntelliJ IDEA.
  User: 仁
  Date: 2021-03-13
  Time: 12:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>公告</title>
    <base href="<%=request.getContextPath()%>/"/>
    <link rel="stylesheet" href="webjars/layui/2.5.5/css/layui.css">
</head>
<body>
<div class="layui-container">
    <div class="layui-collapse">
        <div class="layui-colla-item">
            <div class="layui-colla-title">查询条件</div>
            <div class="layui-colla-content layui-show">
                <form class="layui-form layui-inline">

                    <div class="layui-inline">
                        <input type="text" class="layui-input" id="drugname" placeholder="根据发布时间进行查询">
                    </div>
                    <div class="layui-input-inline">
                        <button type="button" class="layui-btn" id="chaxun" onclick="search()" data-type="reload">查询</button>
                    </div>
                    <div class="layui-input-inline">
                        <button type="button" class="layui-btn" id="tianjia" onclick="add()" data-type="reload">发布公告</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script type="text/html" id="toolbar">
        <button type="button" class="layui-btn" id="tjin">发布公告</button>
    </script>
    <table id="roleTb" lay-filter="roleTb"></table>
</div>
<%--    添加功能--%>
<div id="addmk" style="display: none">
    <form class="layui-form" lay-filter="addform" action="" style="padding: 50px" id="addDruginfo">
        <div class="layui-form-item">
            <label class="layui-form-label">标题名称:</label>
            <div class="layui-input-block">
                <input id="a1" type="text" name="totalname" required  lay-verify="required" placeholder="请输入标题名称" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">请输入发布内容:</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" class="layui-textarea" name="neirong"></textarea>
            </div>
        </div>

    </form>
</div>
<script src="webjars/layui/2.5.5/layui.js"></script>
<script>
    layui.use(['form','table','jquery'], function(){
        let table=layui.table;
        table.render({
            id:"roleTb",
            elem:"#roleTb",
            url:"gonggao/gonggaoindex",
            cols: [[
                {title:"标题",field: "biaoti",width: '20%'},
                {title:"内容",field: "neirong",width: '50%'},
                {title:"发布时间",field:"shijian"},
                {title:"发布人编号",field:"managerid"},
                {title:"发布人姓名",field:"manager"},
            ]]
        })
    })

    function search() {
        layui.use(["jquery","table"],function () {
            let $=layui.jquery;
            let drugname=$("#drugname").val();
            let where = {drugname:drugname};
            layui.table.reload("roleTb",{where});
        })
    }

    function add() {
        layui.use(["jquery","table","layer"],function () {
            let $=layui.jquery;
            let table=layui.table;
            let layer=layui.layer;
            $("#addDruginfo")[0].reset();
            layer.open({
                type:1,
                content:$('#addmk'),
                area:["500px","320px"],
                btn:["确定","取消"],
                title:"发布公告信息",
                yes(){
                    let parms=  layui.form.val("addform")
                    $.post("/druginfo/addDruginfo",parms)
                        .done(({msg})=>{
                            // layer.msg(msg)
                            console.log(msg);
                            layer.close(layer.index);
                            table.reload("infoTb")
                        });
                },
            });
        });
    }
    
</script>
</body>
</html>
